W2. Matrix Factorizations
1. Theory
1.1 Elementary Matrices
Before diving into elementary matrices, recall that an identity matrix
An elementary matrix is a matrix obtained by performing a single elementary row operation on an identity matrix
- Swap two rows (interchange)
- Multiply a row by a nonzero scalar (scaling)
- Add a multiple of one row to another row (row addition)
These operations are fundamental to Gaussian elimination, the systematic method for solving systems of linear equations by transforming a matrix to row echelon form (upper triangular form). Elementary matrices are powerful because they allow us to express these row operations as matrix multiplications: every step of row reduction can be expressed as multiplication by an elementary matrix.
Why does this matter? By representing row operations as matrices, we can track all the steps of Gaussian elimination algebraically. This leads directly to matrix factorizations like LU decomposition, which we’ll study later.
There are three types of elementary matrices, corresponding to the three row operations:
- Row Swap
: swaps rows and of the identity matrix. Multiplying swaps rows and of . - Row Scaling
: multiplies row of the identity by a nonzero scalar . Multiplying scales row of by . - Row Addition
: adds times row to row in the identity. Multiplying adds times row to row of .
1.1.1 Inverses of Elementary Matrices
Each elementary matrix is invertible, and its inverse is another elementary matrix that “undoes” the operation:
(swapping twice returns to original) (scale by to undo) (subtract what was added)
1.1.2 Determinants of Elementary Matrices
(row swap flips sign) (adding a multiple of one row to another does not change the determinant)
1.1.3 Fundamental Theorem
Every invertible matrix can be expressed as a product of elementary matrices:
This is the theoretical basis of Gauss-Jordan elimination: reducing
1.2 Right Multiplication by Elementary Matrices
A crucial distinction: when an elementary matrix multiplies
| Operation | Left Multiply |
Right Multiply |
|---|---|---|
| Row swap |
Swaps rows |
Swaps columns |
| Row scale |
Scales row |
Scales column |
| Row add |
Adds |
Adds |
| Effect on | Row space | Column space |
| Preserves | Column relations | Row relations |
| Use case | Solving |
Solving |
For example, if
1.2.1 Properties of Permutation Matrices
A permutation matrix
For symmetric matrices, we often use symmetric permutations of the form
1.3 Triangular Systems
Before discussing why we decompose matrices, we need to understand what makes triangular systems special. A matrix is upper triangular if all entries below the main diagonal are zero (e.g.,
Why are triangular systems important? When solving a system of equations
1.3.1 Forward Substitution (Lower Triangular)
For a lower triangular system
Example: For
- First:
- Second:
- Third:
The general formula is:
Or more compactly:
1.3.2 Back Substitution (Upper Triangular)
For an upper triangular system
Example: For
- Last:
- Second:
- First:
The general formula is:
Or more compactly:
1.4 LU Decomposition
LU decomposition (also called LU factorization) is one of the most important matrix factorizations in linear algebra. It expresses a matrix
The big idea: Instead of solving
- First solve
(forward substitution, fast) - Then solve
(back substitution, fast)
Since
Connection to Gaussian elimination: The matrix
To ensure uniqueness, we require
1.4.1 Deriving LU from Gaussian Elimination
During Gaussian elimination, each row operation corresponds to an elementary matrix. If we reduce
The product
1.4.2 Existence and Uniqueness
An invertible matrix
What’s a leading principal minor? The
(just the top-left entry) (top-left block) (the full matrix)
Why does this matter? Each leading principal minor corresponds to a pivot during Gaussian elimination. If
If
Example of failure: The matrix
1.4.3 Why LU is Efficient
If we need to solve
Example: For
1.5 Pivoting
When performing Gaussian elimination, we work our way down the diagonal, using each diagonal element (called a pivot) to eliminate entries below it. But what happens if a pivot is zero? We can’t divide by zero! Even if a pivot is very small (close to zero), dividing by it can cause huge numerical errors due to round-off in computer arithmetic.
The solution: pivoting. We swap rows (and possibly columns) to place a better (larger in absolute value) element in the pivot position. This process is called pivoting, and it’s essential for both theoretical correctness and numerical stability.
What is numerical stability? In theory, we can work with exact arithmetic. In practice, computers use floating-point numbers with limited precision. Small errors can accumulate and grow. A numerically stable algorithm is one that doesn’t let these errors blow up. Pivoting helps ensure stability by avoiding division by small numbers.
1.5.1 Partial Pivoting
Partial pivoting searches the current column below the diagonal for the largest element in absolute value, then swaps it into the pivot position.
Algorithm at step
- Find
such that - Swap rows
and - Continue elimination
The result is the factorization:
Partial pivoting always exists for any invertible matrix
1.5.2 Complete Pivoting
Complete pivoting searches the entire remaining submatrix (not just one column) for the largest element:
Algorithm at step
- Find
such that - Swap rows
and (using ) - Swap columns
and (using ) - Continue elimination
The result is:
1.5.3 Numerical Stability
The growth factor measures how much entries grow during elimination:
- No pivoting:
can reach (catastrophic) - Partial pivoting:
(worst case), but in practice is small - Complete pivoting:
| Partial | Complete | |
|---|---|---|
| Operation | Row swaps | Row + column swaps |
| Search cost | ||
| Total extra cost | ||
| Stability | Usually sufficient | Best possible |
| Growth bound | ||
| Form | ||
| Usage | Default in practice | Ill-conditioned/rank-deficient |
1.5.4 Rook Pivoting
Rook pivoting is a compromise between partial and complete pivoting: it searches both the current row and column but stops at the first element that is largest in both its row and column. It is almost as stable as complete pivoting with expected cost
1.5.5 Solving Systems with Complete Pivoting
To solve
- Compute
- Rewrite:
- Let
, then solve (forward substitution), then (back substitution) - Recover
(reverse column permutation)
1.5.6 Determinant with Pivoting
For a permutation matrix
(row swap) (column swap) (simultaneous row and column swap)
In the decomposition
1.5.7 When to Use Which
Partial pivoting suffices for:
- Most well-conditioned problems
- Diagonally dominant matrices
- Symmetric positive definite matrices (no pivoting needed at all)
Complete pivoting is needed for:
- Ill-conditioned matrices (
): A matrix is ill-conditioned if small changes in the input can cause large changes in the output. The condition number measures this sensitivity. Large means the problem is difficult numerically. - Rank-deficient matrices: Matrices where some rows/columns are linearly dependent (not full rank), used when determining the rank
- Computing the null space: Finding all vectors
such that - When backward stability is critical: Applications requiring maximum possible accuracy
1.6 LDU Decomposition
The LU decomposition can be refined further. From
is a diagonal matrix containing the pivots from is unit upper triangular (upper triangular with 1’s on the diagonal)
Why do this? Separating the diagonal pivots into
1.6.1 Symmetric Case:
If
1.7 Symmetric Positive Definite Matrices and Cholesky Decomposition
A matrix
A symmetric matrix
What does this mean intuitively? The expression
1.7.1 Sylvester’s Criterion
Sylvester’s Criterion provides a practical test for positive definiteness: a symmetric matrix
This is incredibly useful because checking the definition (
1.7.2 Cholesky Decomposition
For SPD matrices, the
We can then absorb these square roots into
If we define
We typically just write this as
Advantages of Cholesky:
- Costs only
flops (half of LU) - Numerically stable without pivoting
- Requires only storing one triangular factor
1.8 Matrix Inversion
The inverse of a matrix
Why do we care about inverses? If
1.8.1 The 2x2 Inverse Formula
For a
Memory trick: Swap the diagonal entries (
1.8.2 Gauss-Jordan Method
To find
Why does this work? The row operations correspond to multiplying by elementary matrices. If we reduce
This means
So
1.8.3 Properties Preserved by Inversion
If
- Is triangular if
is triangular (upper stays upper, lower stays lower) — provable by induction - Is symmetric if
is symmetric — because - Is NOT necessarily tridiagonal even if
is tridiagonal — the inverse is generally a full/dense matrix - Does NOT necessarily have integer entries even if
does — the inverse involves division by the determinant
1.9 Matrix Multiplication and Row/Column Interpretation
Matrix multiplication can be understood in several ways. Beyond the standard “dot product of row
Row perspective: Each row of the product
Why? When you compute
Column perspective: Each column of
Example: If
This perspective is crucial for understanding how elementary matrices work: left multiplication affects rows, right multiplication affects columns.
2. Definitions
- Elementary Matrix: A matrix obtained by performing a single elementary row operation on the identity matrix.
- Row Swap Matrix (
): An elementary matrix that swaps rows and ; also called a permutation matrix. - Row Scaling Matrix (
): An elementary matrix that multiplies row by a nonzero scalar . - Row Addition Matrix (
): An elementary matrix that adds times row to row . - LU Decomposition: A factorization
where is unit lower triangular and is upper triangular. - Leading Principal Minor (
): The determinant of the top-left submatrix of a matrix. - Partial Pivoting: A pivoting strategy that swaps rows to place the largest element (in absolute value) in the current column into the pivot position, yielding
. - Complete Pivoting: A pivoting strategy that swaps both rows and columns to place the largest element in the remaining submatrix into the pivot position, yielding
. - Rook Pivoting: A compromise pivoting strategy that searches both the current row and column for the first element that is largest in both.
- Growth Factor (
): The ratio of the largest entry appearing during elimination to the largest entry of the original matrix; measures numerical stability. - LDU Decomposition: A factorization
where is unit lower triangular, is diagonal (containing the pivots), and is unit upper triangular. - Symmetric Positive Definite (SPD) Matrix: A symmetric matrix
such that for every nonzero vector . - Sylvester’s Criterion: A symmetric matrix is positive definite if and only if all its leading principal minors are positive.
- Cholesky Decomposition: For SPD matrices,
where is lower triangular with positive diagonal entries. - Matrix Equivalence: Two matrices
and are equivalent if there exist invertible matrices and such that . - Gauss-Jordan Elimination: A method to compute
by row-reducing the augmented matrix to .
3. Formulas
- Inverse of Row Swap:
- Inverse of Row Scaling:
- Inverse of Row Addition:
- Determinant of Row Swap:
- Determinant of Row Scaling:
- Determinant of Row Addition:
- LU Decomposition:
(exists when all leading principal minors ) - LU with Partial Pivoting:
(exists for any invertible ) - LU with Complete Pivoting:
(exists for any matrix , including singular) - LDU Decomposition:
where and - Symmetric LDU:
(when is symmetric) - Cholesky Decomposition:
(when is symmetric positive definite) - Cholesky Cost:
flops - LU Cost:
flops for factorization, flops per solve - Forward Substitution:
- Back Substitution:
- Determinant from PAQ = LU:
- 2x2 Inverse:
- Transpose of Inverse:
- Invertible Matrix as Product of Elementary Matrices:
4. Practice
4.1. Matrix Inverse Using Permutation Matrices (Lab 2, Task 1)
For given matrix A find its inverse using permutation matrices.
Click to see the solution
Solution:
Step 1. Transform the matrix to diagonal form.
Step 2. Transform the matrix to its inverse form.
Answer:
4.2. Gaussian Elimination and LU Factorization (Lab 2, Task 2)
Let us show the equivalence of Gaussian Elimination and matrix factorization.
Click to see the solution
Solution:
Step 1. Find upper triangular matrix using Gaussian elimination.
Step 2. Find upper triangular matrix using matrix operators.
Step 3. Combine and find
where
Answer:
4.3. Solving Linear Systems with LU Decomposition and Forward/Backward Substitution (Lab 2, Task 3)
Solve given matrix equation using LU decomposition and forward/backward substitution.
Click to see the solution
Solution:
Step 1. Use LU decomposition.
Step 2. Solve
Step 3. Solve
Answer:
4.4. LDU Decomposition (Lab 2, Task 4)
Given matrices:
Find the LDU decomposition.
Click to see the solution
Solution:
Step 1. Factor out the diagonal from
Step 2. Write the LDU factorization.
Answer:
4.5. Cholesky Decomposition of Symmetric Positive Definite Matrix (Lab 2, Task 5)
Find the Cholesky decomposition
Click to see the solution
Solution:
Step 1. Show the procedure of decomposition in symbolic form.
Step 2. Substitute numerical values.
Step 3. Write
Answer:
4.6. Solving System with Cholesky Decomposition (Lab 2, Task 6)
Solve given equation for positive definite symmetric matrix
Click to see the solution
Solution:
Step 1. Use Cholesky decomposition
Step 2. Solve
Step 3. Solve
Answer:
4.7. Solving Systems with Given LU Factorization (Part 1) (Assignment 2, Task 1)
Solve the equation
Click to see the solution
Solution:
Step 1. Identify
Step 2. Solve
Step 3. Solve
Answer:
4.8. Solving Systems with Given LU Factorization (Part 2) (Assignment 2, Task 2)
Solve the equation
Click to see the solution
Solution:
Step 1. Solve
Step 2. Solve
Answer:
4.9. Solving Systems with Given LU Factorization (Part 3) (Assignment 2, Task 3)
Solve the equation
Click to see the solution
Solution:
Step 1. Solve
Step 2. Solve
Answer:
4.10. Solving Systems with Given LU Factorization (Part 4) (Assignment 2, Task 4)
Solve the equation
Click to see the solution
Solution:
Step 1. Solve
Step 2. Solve
Answer:
4.11. Solving Systems with Given LU Factorization (Part 5) (Assignment 2, Task 5)
Solve the equation
Click to see the solution
Solution:
Step 1. Solve
Step 2. Solve
Answer:
4.12. Matrix Multiplication and Row Interpretation (Tutorial 2, Task 1)
Matrix multiplication can be interpreted through linear combinations. Show how each row of the product
Click to see the solution
Solution:
Step 1. Compute
Step 2. Express the first row as a linear combination of rows of
Step 3. Express the second row as a linear combination of rows of
Answer: Each row of
4.13. Effect of Elementary Matrices on Rows and Columns (Tutorial 2, Task 2)
Describe the rows of
Click to see the solution
Solution:
Rows of
When
- 1st row of
- 2nd row of
This is a row addition operation: row 1 gets row 1 plus 7 times row 2.
Columns of
When
- 1st column of
- 2nd column of
This is a column addition operation: column 2 gets 7 times column 1 plus column 2.
Answer: Left multiplication by
4.14. Elementary Matrices and Matrix Products (Tutorial 2, Task 3)
Write down the 3 by 3 matrices that produce these elimination steps: a)
Then compute: (i)
Click to see the solution
Solution:
Step 1. Write the elementary matrices.
Step 2. Compute
Step 3. Compute
Answer:
(row 3 feels effect of row 1) (row 3 feels no effect from row 1)
4.15. LU Decomposition by Elimination (Part a) (Tutorial 2, Task 4a)
Apply elimination to produce the factors
Click to see the solution
Solution:
Step 1. Perform Gaussian elimination to get
Step 2. Find the elementary matrix
Answer:
4.16. LU Decomposition by Elimination (Part b) (Tutorial 2, Task 4b)
Apply elimination to produce the factors
Click to see the solution
Solution:
Step 1. Perform Gaussian elimination to get
Step 2. Find
Answer:
4.17. Conditions for Matrix to be Nonsingular (Tutorial 2, Task 5a)
Under what conditions is the following product nonsingular?
Click to see the solution
Solution:
Step 1. Identify the matrix structure.
We have
(lower triangular with 1’s on diagonal) (diagonal) (upper triangular with 1’s on diagonal)
Step 2. Apply the determinant property.
Since
Step 3. Determine nonsingularity condition.
Matrix
Answer:
4.18. Solving System with LDU Decomposition (Tutorial 2, Task 5b)
Solve the system
where the full decomposition is
Click to see the solution
Solution:
Step 1. Solve
Step 2. Now we need to solve
This gives:
Step 3. Solve by back substitution.
Answer:
4.19. Find L and D from Upper Triangular Matrix (Tutorial 2, Task 6)
What are
Click to see the solution
Solution:
Step 1. Identify the structure of
Since
- The pivots are the diagonal entries
- No elimination is needed
Step 2. Extract
Step 3. Find
For the
Answer:
4.20. Relationship Between Matrix Inverses (Tutorial 2, Task 7)
If the inverse of
Click to see the solution
Solution:
Step 1. Start with the given condition.
Given:
This means:
Step 2. Show that
We want to show that
Starting from
Since
This shows that
Step 3. Verify it’s also a left inverse.
From
By properties of invertible matrices, if a right inverse exists and
Answer: Since
4.21. Properties Preserved by Matrix Inversion (Tutorial 2, Task 8)
If
is triangular → is triangular ✓ is symmetric → is symmetric ✓ is tridiagonal → is tridiagonal ✗All entries are whole numbers →
has whole numbers ✗All entries are fractions →
has fractions ✓
Click to see the solution
Solution:
Property (a): Triangular matrices
If
By the block matrix inverse formula:
By induction,
Property (b): Symmetric matrices
If
So
Property (c): Tridiagonal matrices
Counterexample:
Computing
This is not tridiagonal. ✗
Property (d): Integer entries
Counterexample:
Property (e): Fractional entries
If all entries of
The inverse still involves only division, resulting in fractional entries. ✓
Answer: Properties (a), (b), and (e) are preserved. Properties (c) and (d) are NOT preserved.
4.22. Invertibility Conditions for Triangular Matrices (Part a) (Tutorial 2, Task 9a)
Under what conditions on their entries are the following matrices invertible?
Click to see the solution
Solution:
Step 1. Apply Gauss-Jordan elimination to find invertibility conditions.
Step 2. Swap rows to bring
Swap rows 1 and 3:
This requires:
Step 3. Eliminate below first pivot.
This requires:
Step 4. Eliminate in row 3, column 2.
This requires:
Answer: Matrix
4.23. Invertibility Conditions for Block Diagonal Matrices (Tutorial 2, Task 9b)
Under what conditions on their entries is the following matrix invertible?
Click to see the solution
Solution:
Step 1. Recognize the block diagonal structure.
where
Step 2. Apply the block matrix determinant formula.
Step 3. Determine invertibility condition.
Matrix
This requires both:
(the block is invertible) (the scalar is nonzero)
Answer: Matrix
4.24. Compute 2×2 Matrix Inverses (Tutorial 2, Task 10)
Find the inverses (directly or from the 2×2 formula) of:
Click to see the solution
Solution:
The 2×2 inverse formula:
For matrix A:
For matrix B:
(valid for
For matrix C:
Answer:
(for )
4.25. Compute Matrix Inverse Using Gauss-Jordan Elimination (Tutorial 2, Task 11)
Invert this matrix
Click to see the solution
Solution:
Step 1. Set up the augmented matrix
Step 2. Apply row operations to eliminate below first pivot.
Step 3. Eliminate in row 2, column 3.
Answer:
4.26. Matrix Powers and General Pattern (Part a) (Tutorial 2, Task 12a)
By experiment with
Click to see the solution
Solution:
Step 1. Compute the matrix squared.
Step 2. Compute the matrix cubed.
Step 3. Identify the pattern.
For
Answer:
4.27. Matrix Powers and Commutativity (Part b) (Tutorial 2, Task 12b)
By experiment with
Click to see the solution
Solution:
Step 1. Compute the matrix squared.
Step 2. Compute the matrix cubed.
Step 3. Identify the pattern.
For
Answer:
4.28. Matrix Inverse Through Gauss-Jordan (Tutorial 2, Task 12c)
Find
Click to see the solution
Solution:
Step 1. Set up the augmented matrix.
Step 2. Eliminate above the second pivot.
Step 3. Normalize the first row.
Answer:
4.29. General Pattern for Elementary Lower Triangular Matrices (Part a) (Tutorial 2, Task 13a)
By experiment or Gauss-Jordan method, find
Click to see the solution
Solution:
Step 1. Compute the matrix squared.
Step 2. Compute the matrix cubed.
Step 3. Identify the general pattern.
Answer:
4.30. Inverse of Elementary Lower Triangular Matrix (Part b) (Tutorial 2, Task 13b)
Find
Click to see the solution
Solution:
Step 1. Use the pattern from Part a with
From the pattern
Setting
Step 2. Verify by multiplication.
Answer:
4.31. Inverse of Modified Lower Triangular Matrix (Part c) (Tutorial 2, Task 13c)
Find
Click to see the solution
Solution:
Step 1. Set up the augmented matrix
Step 2. Eliminate below the first pivot.
Step 3. Eliminate below the second pivot.
Answer: